package com.ruoyi.common.utils.flow;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
import com.warm.flow.core.entity.Task;
import com.warm.flow.orm.entity.FlowTask;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author YanWenliang
 * @date 2025/1/3 16:39
 * @desciption: 工作流转换类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FlowDTO extends FlowTask {

    private String submitUser;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date submitTime;

    private Map<String, Object> businessValue;

    public FlowDTO(String submitUser) {
        this.submitUser = submitUser;
    }

    public FlowDTO(BaseEntity task) {
        this.submitUser = task.getCreateBy();
        this.submitTime = task.getCreateTime();
        this.businessValue = new LinkedHashMap<>();
    }
}
